Software programs for creating text-based documents, such as word processing and desktop publishing programs, often allow the author of a document to incorporate visual elements, such as pictures, charts, and graphs into documents. The author of the document typically places the visual elements in the desired locations, and a text layout routine automatically places the text around the visual elements. Certain text-processing programs place text around a visual element by first surrounding the visual element with a "bounding rectangle," which serves as a constraint, around which the text layout routine places the text. The bounding rectangle is selected such that the entire visual element is located within the bounding rectangle.
Using bounding rectangles as text-layout constraints can make the resulting document difficult to read when the visual elements have jagged or uneven shapes. In this situation, bounding rectangles surrounding the visual elements may leave relatively large areas of blank space in certain lines of text. Forcing a reader's eye to jump over these blank spaces makes the text difficult to read and increases the page space required to display the document. These shortcomings are exaggerated when a visual element has a serpentine shape or includes empty interior spaces.
Text-based documents have improved readability, require less display space, and take on a professional, polished appearance when the text wraps around, or form-fits, to the shape of the visual elements. To form-fit text to the shape of visual elements within a document, a constraint that follows the edge of the visual element typically is defined first. A text layout routine may then place the text around the constraint. Text-processing programs have been developed with the ability to bound visual elements with polygon constraints. Text layout routines within these programs have also been developed with the ability to place text around the polygon constraints.
However, these prior text-processing programs experience a number of shortcomings. A first shortcoming arises when the text is rendered in a "rich-text" format. Rich-text formatting allows the user to change the properties of text, such as color, style, font type, and font size, on a character-by-character basis. Text rendered in a rich-text format can therefore vary in height and width depending on the font size and type, as well as other formatting options, including bold, subscript, superscript, and so forth. Moreover, changing the width of the field into which a rich-text string is placed can alter the height of the text string. For this reason, breaking a rich-text string into a number of horizontal spans to fit around one portion of a constraint can cause the text to increase in height and overlap another portion of the constraint.
Prior text-processing programs are not configured to address the problems caused by rich-text formatting. As a result, text that is intended to wrap around a visual element may, in fact, overlap the constraint and interfere with the visual element. This problem can be overcome by increasing the required clearance between the constraint and the text, but this solution decreases the precision of text placement and, thus, reduces the readability of the text. Alternatively, the text layout engine may search iteratively for an acceptable text placement.
For example, each time an attempted text placement overlaps a constraint, the text layout engine may invalidate that text placement solution and attempt another solution. Because the text layout routine takes some time to perform its task, causing the text layout routine to search iteratively for text placement solutions can slow the text-processing program to the point of unacceptable performance. The processing speed of the text layout routine can usually increased only at the cost of decreased text-placement precision. At present, text-processing programs can be improved both in processing speed and in text-placement precision.
Another problem results from the nonportability of previous text layout routines. A software development company, such as MICROSOFT, may have a number of text-processing application programs that use text layout routines. For example, a word processing program, a desktop publishing program, a program for creating Internet home pages, may each use a text layout routine. At present, each application program includes its own text layout routine, which is embedded within the program code and tailored to its particular host application program. Maintenance must therefore be performed for the text layout routines of each program individually. For this reason, it is cumbersome to maintain and upgrade the text layout routines. In addition, each text layout routine may operate somewhat differently, which may confuse or aggravate a user who has more than one of the application programs.
There is, therefore, a need in the art for a text layout program having improved processing speed and text-placement precision for use with rich-text documents. There is a further need for a portable text layout program that may be accessed by an number of different text-processing application programs.